<%@ page import="org.belkodevelop.user.domain.User" %>
<%@ page import="org.belkodevelop.role.RoleConstants" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="brand" href="/">MonitorAD</a>
            <div class="nav-collapse collapse">
                <ul class="nav">
                    <li><a href="/"><spring:message code="nav_bar.main_menu.main"/></a></li>
                    <li><a href="/about.html"><spring:message code="nav_bar.main_menu.about"/></a></li>

                    <%
                        User user = (User) request.getAttribute("user");
                        if (user == null) {
                    %>

                        <li><a href="/cabinet/"><spring:message code="nav_bar.main_menu.cabinet"/></a></li>

                    <% } else if (user.getRoles().contains(RoleConstants.PATIENT_ROLE)) { %>

                        <li><a href="/cabinet/"><spring:message code="nav_bar.main_menu.cabinet"/></a></li>

                    <% } else if (user.getRoles().contains(RoleConstants.DOCTOR_ROLE)) { %>

                        <li><a href="/doctor/"><spring:message code="nav_bar.main_menu.cabinet"/></a></li>

                    <% } else if (user.getRoles().contains(RoleConstants.ADMIN_ROLE)) { %>

                        <li><a href="/admin/"><spring:message code="nav_bar.main_menu.cabinet"/></a></li>

                    <% } else { %>

                        <li><a href="/cabinet/"><spring:message code="nav_bar.main_menu.cabinet"/></a></li

                    <% } %>


                    <c:if test="${empty user}">
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown"><spring:message code="nav_bar.main_menu.registration"/><b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="/registration-patient.html">Я пациент</a></li>
                                <li><a href="/registration-doctor.html">Я врач</a></li>
                                <!--<li><a href="#">Демо</a></li>-->
                            </ul>
                        </li>
                    </c:if>
                <c:choose>
                    <c:when test="${empty user}">
                        <c:if test="${pageContext.request.servletPath != '/WEB-INF/views/login.jsp'}">
                            <li>
                            <div style="padding-left:20px;">
                                <form class="navbar-form pull-right" method="post" action="/login.do">
                                    <input class="span2" type="text" placeholder="Эл. почта" name="login">
                                    <input class="span2" type="password" placeholder="Пароль" name="password">
                                    <button type="submit" class="btn">Войти</button>
                                </form>
                            </div>
                            </li>
                        </c:if>
                    </c:when>
                    <c:otherwise>
                        <li><a href="/cabinet/logout.do">Выйти</a></li>
                    </c:otherwise>
                </c:choose>
                </ul>
                <div style="padding-top:5px;padding-left: 10px;" class="navbar-inner pull-right">
                    <select id="selectLangSelect" style="width:60px">
                        <option value="ru" ${pageContext.response.locale == 'ru' ? 'selected' : ''}>RU</option>
                        <option value="ua" ${pageContext.response.locale == 'ua' ? 'selected' : ''}>UA</option>
                        <option value="en" ${pageContext.response.locale == 'en' ? 'selected' : ''}>EN</option>
                    </select>
                    <script>
                        $(function(){
                            $('#selectLangSelect').change(function(){
                                window.location.search = "?lang=" + $(this).val();
                            });
                        });
                    </script>
                </div>

            </div><!--/.nav-collapse -->
        </div>
    </div>
</div>

<div class="container">